package com.itheima.controller;

import com.itheima.domain.Test;
import com.itheima.domain.User;
import com.itheima.service.UserRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserRoleController {
    @Autowired
    private UserRole userRole;

//    @RequestMapping(value = "/userInfo", method = RequestMethod.POST)
    @PostMapping(path="/userInfo")
    public User queryUserInfo(@RequestBody Test test) {
        return userRole.queryUserInfo(test.getUid());
    }
    @RequestMapping(value = "/addUserRole", method = RequestMethod.POST)
    public String addUserRole(@RequestBody User user){
        try {
            userRole.addUserRole(user);
        }catch(Exception e) {
            e.printStackTrace();
            return "fail";
        }
        return  "success";
    }


}
